#
# 构建 nginx 1.10.2
#

FROM e7sky/was:3.7
MAINTAINER joen kai168@126.com

ENV NGINX_VERSION 1.11.13
ENV OPENSSL_VERSION 1.0.2j
ENV PCRE_VERSION 8.41
ENV ZLIB_VERSION 1.2.11

#COPY software/nginx-1.10.2.tar.gz software/openssl-1.0.2j.tar.gz software/pcre-8.41.tar.gz software/zlib-1.2.11.tar.gz /was/soft/
RUN apk add --no-cache --virtual .build-deps g++ make perl-dev curl \
			&& cd /was/soft \
			&& gosu was curl -fSL -O http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz \
			&& gosu was curl -fSL -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz \
			&& gosu was curl -fSL -O https://ftp.pcre.org/pub/pcre/pcre-$PCRE_VERSION.tar.gz \
			&& gosu was curl -fSL -O http://www.zlib.net/zlib-$ZLIB_VERSION.tar.gz \
      && gosu was tar xzf nginx-$NGINX_VERSION.tar.gz \
      && gosu was tar xzf openssl-$OPENSSL_VERSION.tar.gz \
      && gosu was tar xzf pcre-$PCRE_VERSION.tar.gz \
      && gosu was tar xzf zlib-$ZLIB_VERSION.tar.gz \
      && cd /was/soft/nginx-$NGINX_VERSION \
      && gosu was ./configure \
				--prefix=/was/run/nginx \
				--user=was \
				--group=g_was \
				--with-http_stub_status_module \
				--with-http_gzip_static_module \
				--with-http_ssl_module \
				--with-threads \
				--with-openssl=/was/soft/openssl-$OPENSSL_VERSION \
				--with-zlib=/was/soft/zlib-$ZLIB_VERSION \
				--with-pcre=/was/soft/pcre-$PCRE_VERSION \
				# --with-perl \
      && gosu was make -j$(getconf _NPROCESSORS_ONLN) && gosu was make install \
      && rm -Rf /was/soft/* \
			&& apk del .build-deps


EXPOSE 80

CMD [ "/was/run/nginx/sbin/nginx","-g","daemon off;" ]



#apk add --no-cache --virtual .build-deps g++ make perl-dev
#gosu was ./configure --prefix=/was/run/nginx --user=was --group=g_was --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-openssl=/was/soft/openssl-1.0.2j --with-zlib=/was/soft/zlib-1.2.11 --with-pcre=/was/soft/pcre-8.41
#gosu was make && gosu was make install
